<!--{template common/header_simple_start}-->
<link href="static/css/common.css?{VERHASH}" rel="stylesheet" media="all">
<script src="user/scripts/register.js?{VERHASH}"></script>
<script type="text/javascript" src="static/js/jquery.leftDrager.js?{VERHASH}"></script>
<!--{template common/header_simple_end}-->
<div class="bs-container clearfix">
<div class="bs-left-container  clearfix"> 
  <!--{template left}--> 
</div>
<div class="left-drager">
  <div class="left-drager-op">
    <div class="left-drager-sub"></div>
  </div>
</div>
<div class="bs-main-container  clearfix" >
<div class="main-content" style="padding:20px;">
  <form id="accountform" name="accountform" class="form-horizontal form-horizontal-left" role="form" action="user.php?mod=password" method="post" onsubmit="account_submit();return false">
    <input type="hidden" name="accountedit" value="true" />
    <input type="hidden" name="uid" value="$uid" />
    <input type="hidden" name="formhash" value="{FORMHASH}" />
    <div class="form-group">
        <label class="control-label" for="email">登录邮箱</label>
          <input type="text" id="email" class="form-control" name="email" value="$user[email]">
        <span id="chk_email" class="help-inline"> <span id="suc_email"></span><kbd class="p_chk"></kbd> </span> 
    
      <!--{if $user[groupid]==8}-->
      
        <ul class="help-block" style="color:#999">
          <li class="text-warning">登录邮箱($user[email])等待验证中...。帐号功能受限</li>
          <li>系统已经向该邮箱发送了一封验证激活邮件，请查收邮件，进行验证激活。</li>
          <li>如果没有收到验证邮件，您可以<a href="javascript:;" onclick="$('email').focus()">更换登录邮箱</a>或者<a id="sendmail" href="user.php?mod=password&sendmail=1">重新接收验证邮件</a></li>
        </ul>
      
      <!--{/if}--> 
    </div>
    <div class="form-group">
      <label class="control-label" for="nickname" >用户名</label>
        <input type="text" name="nickname" class="form-control" value="$user[nickname]" autocomplete="off" id="nickname" placeholder="留空，不设置">
     	<span id="chk_nickname" class="help-inline"> <span id="suc_nickname"></span> <kbd  class="p_chk"></kbd> </span>
    </div>
    <div class="form-group">
      <label class="control-label" for="phone" >手机号码</label>
        <input type="text" name="phone" class="form-control" value="$user[phone]" autocomplete="off" id="phone" placeholder="微信绑定手机号">
        <span id="chk_phone" class="help-inline">选填，微信绑定的手机号码，员工关注企业号时，会根据员工微信绑定的手机来匹配。</span>
    </div>
    <div class="form-group">
      <label class="control-label" for="weixinid" >微信号</label>
        <input type="text" name="weixinid" class="form-control" value="$user[weixinid]" autocomplete="off" id="weixinid" placeholder="微信号" >
        <span id="chk_weixinid" class="help-inline">选填，员工微信号，员工关注企业号时，会根据员工微信号来匹配。如果已经关注，此项不能修改。</span>
    </div>
    <div class="form-group">
      <label class="control-label" for="password0" required>原密码</label>
        <input type="password" name="password0" class="form-control" autocomplete="off" id="password0" placeholder="这里输入原密码">
        <span id="chk_password0" class="help-inline"> <span id="suc_password0"></span> <kbd  class="p_chk"></kbd> </span>
    </div>
    <div class="form-group">
      <label class="control-label" for="password">新密码</label>
        <input type="password" name="password" class="form-control" autocomplete="off" id="password" placeholder="不修改请留空">
        <span id="chk_password" class="help-inline"> <span id="suc_password"></span> <kbd  class="p_chk"></kbd> </span>
    </div>
    <div class="form-group">
      <label class="control-label" for="password2">确认新密码</label>
        <input type="password" id="password2" class="form-control" name="password2" autocomplete="off" placeholder="不修改请留空" >
        <span id="chk_password2" class="help-inline"> <span id="suc_password2"></span> <kbd  class="p_chk"></kbd> </span>
    </div>
    <!--{if $secqaacheck || $seccodecheck}--> 
    <!--{block sectpl}-->
    <sec>
    <sec>
    <sec>
    <!--{/block}-->
    <div class="form-group">
      <label class="control-label">验证码</label>
      <div class="controls"> 
        <!--{subtemplate common/seccheck}--> 
      </div>
    </div>
    <!--{/if}-->
    
    <div class="form-group">
       <label class="control-label"></label>
       <div class="controls"><input type="button" class="btn btn-primary" value="保存更改" onclick="account_submit()"></div>
    </div>
  </form>
</div>
</div>
<script type="text/javascript" reload="1">
jQuery('.left-drager').leftDrager_layout();
	var orgsel_html=jQuery('#nav').html();
	var lastusername = '{$user[nickname]}', lastpassword = '', lastemail = '{$user[email]}',  stmp = new Array(), modifypwd = true;
	var pwlength = 0;
	var strongpw = new Array();
    var ignoreEmail = false;
    
	checkPwdComplexity($('password'),$('password2'),1);
	jQuery('#password0').on('blur',function(){
		if(jQuery(this).val()==''){
			jQuery('#chk_password0 kbd').html('请输入原密码');
			jQuery(this).parent().addClass('has-error');
		}else{
			jQuery('#chk_password0 kbd').html('');
			jQuery(this).parent().removeClass('has-error');
		}
	});
	jQuery('#email').on('blur',function(){
		var email=jQuery(this).val();
		var warnel=jQuery(this).parent();
		if(email==lastemail){
			jQuery('#chk_email kbd').html('');
			jQuery(this).parent().removeClass('has-error');
		}else{
			var x = new Ajax();
			x.get('user.php?mod=ajax&inajax=yes&infloat=register&handlekey=password&ajaxmenu=1&action=checkemail&email=' + email, function(s) {
				if(s=='succeed'){
					jQuery('#chk_email kbd').html('');
					warnel.removeClass('has-error');
				}else{
					jQuery('#chk_email kbd').html(s);
					warnel.addClass('has-error');
				}
			});
			
		}
	});
	jQuery('#nickname').on('blur',function(){
		var nickname=jQuery(this).val();
		var warnel=jQuery(this).parent();
		if(nickname=='' || nickname==lastusername){
			jQuery('#chk_nickname kbd').html('');
			jQuery(this).parent().removeClass('has-error');
		}else{
			var x = new Ajax();
			x.get('user.php?mod=ajax&inajax=yes&infloat=register&handlekey=password&ajaxmenu=1&action=checkusername&username=' + nickname, function(s) {
				if(s=='succeed'){
					jQuery('#chk_nickname kbd').html('');
					warnel.removeClass('has-error');
				}else{
					jQuery('#chk_nickname kbd').html(s.replace(/<a.+?\/a>/i,''));
					warnel.addClass('has-error');
				}
			});
			
		}
	});
function checkPwdComplexity(firstObj, secondObj, modify) {
	modifypwd = modify || false;
	firstObj.onblur = function () {
		if(firstObj.value != '') {
			var pwmsg = 'succeed';
			if(pwlength > 0) {
				pwmsg += ', 最小长度为 '+pwlength+' 个字符';
			}
			 errormessage(firstObj.id, pwmsg);
		}else{
			errormessage(firstObj.id,  'succeed' );
		}
		checkpassword(firstObj.id, secondObj.id);
	};
	firstObj.onkeyup = function () {
		if(pwlength == 0 || $(firstObj.id).value.length >= pwlength) {
			var passlevels = new Array('','弱','中','强');
			var passlevel = checkstrongpw(firstObj.id);
			
			errormessage(firstObj.id, '<span class="passlevel passlevel'+passlevel+'">密码强度:'+passlevels[passlevel]+'</span>','passlevel');
		}
	};
	secondObj.onblur = function () {
		if(firstObj.value != ''){
			if(secondObj.value == '') {
				if(!modify) errormessage(secondObj.id,  '请再次输入密码' );
			}
		}
		checkpassword(firstObj.id, secondObj.id);
	};
}
function checkpassword(id1, id2) {
	if(!$(id1).value && !$(id2).value) {
		errormessage(id2,  'succeed' );errormessage(id1,  'succeed' );
		return;
	}
	if(pwlength > 0) {
		if($(id1).value.length < pwlength) {
			errormessage(id1, '密码太短，不得少于 '+pwlength+' 个字符');
			return;
		}
	}
	if(strongpw) {
		var strongpw_error = false, j = 0;
		var strongpw_str = new Array();
		for(var i in strongpw) {
			if(strongpw[i] === 1 && !$(id1).value.match(/\d+/g)) {
				strongpw_error = true;
				strongpw_str[j] = '数字';
				j++;
			}
			if(strongpw[i] === 2 && !$(id1).value.match(/[a-z]+/g)) {
				strongpw_error = true;
				strongpw_str[j] = '小写字母';
				j++;
			}
			if(strongpw[i] === 3 && !$(id1).value.match(/[A-Z]+/g)) {
				strongpw_error = true;
				strongpw_str[j] = '大写字母';
				j++;
			}
			if(strongpw[i] === 4 && !$(id1).value.match(/[^A-Za-z0-9]+/g)) {
				strongpw_error = true;
				strongpw_str[j] = '特殊符号';
				j++;
			}
		}
		if(strongpw_error) {
			errormessage(id1, '密码太弱，密码中必须包含 '+strongpw_str.join('，'));
			return;
		}
	}
	errormessage(id2);
	if($(id1).value != $(id2).value) {
		errormessage(id2, '两次输入的密码不一致');
	} else {
		errormessage(id2,  'succeed' );
	}
}
function account_submit(){
	
	//判断用户名
	
	if($('email').value==''){
		jQuery('#email').parent().addClass('has-error');
		return false;
	}else if($('password0').value==''){
		jQuery('#password0').parent().addClass('has-error');
		return false;
	}else if(($('password').value!='' || $('password2').value!='') && $('password').value!=$('password2').value){
		jQuery('#password0').parent().addClass('has-error');
		 return false;
	}
	var p_chks = $('accountform').getElementsByTagName('kbd');
	var flag=0;
	for(i = 0;i < p_chks.length;i++){
		if(p_chks[i].className == 'p_chk' && p_chks[i].innerHTML != ''){
			return false;
		}
	}
	//判定微信号和手机
	var phone=$('phone').value;
	if(phone!='' && phone.match(/^\d+$/)==null ){
		$('phone').focus();
		showmessage('手机号码不合法','danger',1000,1);
		return false;
	}
	var weixinid=$('weixinid').value;
	if(weixinid!='' && weixinid.match(/^[a-zA-Z\d_]{5,}$/)==null ){
		$('weixinid').focus();
		showmessage('微信号不合法','danger',1000,1);
		return false;
	}
	$('accountform').submit();
	return false;
}


</script> 
<!--{template common/footer_simple}--> 